Assembly Language
© Copyright Brian Brown, 1988-2000. All rights reserved.
| Notes | Home Page |


THE HISTORY OF ASSEMBLY LANGUAGE PROGRAMMING, Part 1
home page next page


Early computer systems were literally programmed by hand. Front panel switches were used to enter instructions and data. These switches represented the address, data and control lines of the computer system.To enter data into memory, the address switches were toggled to the correct address, the data switches were toggled next, and finally the WRite switch was toggled. This wrote the binary value on the front panel data switches to the address specified. Once all the data and instruction were entered, the run switch was toggled to run the program.

The programmer also needed to know the instruction set of the processor. Each instruction needed to be manually converted into bit patterns by the programmer so the front panel switches could be set correctly. This led to errors in translation as the programmer could easily misread 8 as the value B. It became obvious that such methods were slow and error prone.

With the advent of better hardware which could address larger memory, and the increase in memory size (due to better production techniques and lower cost), programs were written to perform some of this manual entry. Small monitor programs became popular, which allowed entry of instructions and data via hex keypads or terminals. Additional devices such as paper tape and punched cards became popular as storage methods for programs.

Programs were still hand-coded, in that the conversion from mnemonics to instructions was still performed manually. To increase programmer productivity, the idea of writing a program to interpret another was a major breakthrough. This would be run by the computer, and translate the actual mnemonics into instructions. The benefits of such a program would be

As programmers were writing the source code in mnemonics anyway, it seemed the logical next step. The source file was fed as input into the program, which translated the mnemonics into instructions, then wrote the output to the desired place (paper-tape etc). This sequence is now accepted as common place.

The only advances have been the increasing use of high level languages to increase programmer productivity.

Assembly language programming is writing machine instructions in mnemonic form, using an assembler to convert these mnemonics into actual processor instructions and associated data.

The disadvantages of assembly language programming are


THE PROGRAM TRANSLATION SEQUENCE
developing a software program to accomplish a particular task, the implementor chooses an appropriate language, develops the algorithm (a sequence of steps, which when carried out in the order prescribed, achieve the desired result), implements this algorithm in the chosen language (coding), then tests and debugs the final result.

here is also a probable maintenance phase also associated. The chosen language will undoubtably need to be converted into the appropriate binary bit-patterns which make sense to the target processor (the processor on which the software will be run). This process of conversion is called translation.

The following diagram illustrates the translation sequence necessary to generate machine code from specific languages.


ASSEMBLY LANGUAGE PROGRAMMING
Asemblers are programs which generate machine code instructions from a source code program written in assembly language. The features provided by an assembler are,

In writing assembly language programs for micro-computers, it is essential that a standardized format be followed. Most manufacturers provide assemblers, which are programs used to generate machine code instructions for the actual processor to execute.

The assembler converts the written assembly language source program into a format which run on the processor. Each machine code instruction (the binary or hex value) is replaced by a mnemonic. A mnemonic is an abbreviation which represents the actual instruction.


	+----------+---------+-----------------+
	| Binary   | Hex     | Mnemonic        |
	+----------+---------+-----------------+
	| 01001111 | 4F      | CLRA            | Clears the A accumulator 
	+----------+---------+-----------------+
	| 00110110 | 36      | PSHA            | Saves A acc on stack 
	+----------+---------+-----------------+
	| 01001101 | 4D      | TSTA            | Tests A acc for 0 
	+----------+---------+-----------------+

Mnemonics are used because they

Assemblers also accept certain characters as representing number bases and addressing modes.


	$ prefix or h suffix for hexadecimal
	 $24 or 24h 

	D for decimal numbers
	 24D 67

	B for binary numbers
	 0101111B

	O or Q for octal numbers
	 377O 232Q 

	# for immediate addressing
	 LDAA #$34 

	,X for indexed addressing
	 LDAA 01,X

Assembly language statements are written one per line. A machine code program thus consists of a sequence of assembly language statements, where each statement contains a mnemonic. Each line of an assembly language program is split into four fields, as shown below


	LABEL	OPCODE	OPERAND		COMMENTS

The label field is optional. A label is an identifier (or text string symbol). Labels are used extensively in programs to reduce reliance upon programmers remembering where data or code is located. A label can be used to refer to<